﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.IO;
using System.Web;
using System.Threading.Tasks;
using System.Data;
using BartonExtension;
using ResponseObject;
using SQLWrapper;
using Model.App;
using Model.Images;
using Model.Weixin;
using Services.Common;
using Services.Business;

namespace iShangMai.Controllers.App
{
    public class bizcommentController : ApiController
    {
        [HttpGet]
        public async Task<ZKResponse> GetComments(UInt64 uid,UInt64 bid,int page,int pageSize,string token)
        {
            ZKResponse response = new ZKResponse();
            ISMGetBusinessCommentsRequest request = new ISMGetBusinessCommentsRequest()
            {
                uid = uid,
                bid = bid,
                page = page,
                pageSize = pageSize,
                token = token
            };
            ISMBusinessServiceProvider provider = (ISMBusinessServiceProvider)ISMServiceStack.sharedInstance[ISMServiceStackKeys.BUSINESS];
            ISMServiceModel model = new ISMServiceModel()
            {
                operationIdentifier = ISMBusinessServiceProvider.GET_COMMENTS,
                userinfo = request
            };
            var result = await provider.doProcess(model);
            response.isProcessSuccess = result.isOperationSuccess;
            response.errMsg = result.errorMsg;
            response.userinfo = result.dbReturningState;
            return response;
        }

        [HttpPost]
        public async Task<ZKResponse> CommentBusiness(ISMBusinessCommentRequest request)
        {
            ZKResponse response = new ZKResponse();
            ISMBusinessServiceProvider provider = (ISMBusinessServiceProvider)ISMServiceStack.sharedInstance[ISMServiceStackKeys.BUSINESS];
            ISMServiceModel model = new ISMServiceModel()
            {
                operationIdentifier = ISMBusinessServiceProvider.COMMENT_BIZ,
                userinfo = request
            };
            var result = await provider.doProcess(model);
            response.isProcessSuccess = result.isOperationSuccess;
            response.errMsg = result.errorMsg;
            response.userinfo = result.dbReturningState;
            return response;
        }
    }
}
